<?php
namespace app\daili\controller;
use think\facade\View;
use think\facade\Db;
class Index extends  Base
{
    
    public function index()
    {
      
$loginAdmin=session('dailiAccount');    
header("Content-type:text/html;charset=utf-8");
//设置北京时间为默认时区
date_default_timezone_set('PRC');
//获得当日凌晨的时间戳
$today = strtotime(date("Y-m-d"),time());
//当天的24点时间戳
$end = $today+60*60*24;
$today1=$today-60*60*24;
$today2=$today-60*60*24*2;
$today3=$today-60*60*24*3;
$today4=$today-60*60*24*4;
$today5=$today-60*60*24*5;
$today6=$today-60*60*24*6;
$end1=$end-60*60*24;
$end2=$end-60*60*24*2;
$end3=$end-60*60*24*3; 
$end4=$end-60*60*24*4; 
$end5=$end-60*60*24*5; 
$end6=$end-60*60*24*6; 
     $yonghushu = Db::name('users')->where('uid',$loginAdmin['id'])->count();
     $jinriyonghushu = Db::name('users')->where('time','>',$today)->where('time','<',$end)->where('uid',$loginAdmin['id'])->count();
    
     $dingdanshu = Db::name('order')->where('status',2)->where('dailiuid',$loginAdmin['id'])->count();
     $jinridingdanshu = Db::name('order')->where('status',2)->where('time','>',$today)->where('time','<',$end)->where('dailiuid',$loginAdmin['id'])->count();
     $zongshouru = Db::name('order')->where('status',2)->where('dailiuid',$loginAdmin['id'])->sum('price');
     $jinrizongshouru = Db::name('order')->where('status',2)->where('time','>',$today)->where('time','<',$end)->where('dailiuid',$loginAdmin['id'])->sum('price');
   $zongshouru=round($zongshouru, 2); 
     $jinrizongshouru=round($jinrizongshouru, 2); 
     $dingdan1= Db::name('order')->where('status',2)->where('time','>',$today1)->where('time','<',$end1)->where('dailiuid',$loginAdmin['id'])->count();
     $dingdan2= Db::name('order')->where('status',2)->where('time','>',$today2)->where('time','<',$end2)->where('dailiuid',$loginAdmin['id'])->count();
     $dingdan3= Db::name('order')->where('status',2)->where('time','>',$today3)->where('time','<',$end3)->where('dailiuid',$loginAdmin['id'])->count();
     $dingdan4= Db::name('order')->where('status',2)->where('time','>',$today4)->where('time','<',$end4)->where('dailiuid',$loginAdmin['id'])->count();
     $dingdan5= Db::name('order')->where('status',2)->where('time','>',$today5)->where('time','<',$end5)->where('dailiuid',$loginAdmin['id'])->count();
     $dingdan6= Db::name('order')->where('status',2)->where('time','>',$today6)->where('time','<',$end6)->where('dailiuid',$loginAdmin['id'])->count();
     $yonghu1 = Db::name('users')->where('time','>',$today1)->where('time','<',$end1)->where('uid',$loginAdmin['id'])->count();
     $yonghu2 = Db::name('users')->where('time','>',$today2)->where('time','<',$end2)->where('uid',$loginAdmin['id'])->count();
     $yonghu3 = Db::name('users')->where('time','>',$today3)->where('time','<',$end3)->where('uid',$loginAdmin['id'])->count();
     $yonghu4 = Db::name('users')->where('time','>',$today4)->where('time','<',$end4)->where('uid',$loginAdmin['id'])->count();
     $yonghu5 = Db::name('users')->where('time','>',$today5)->where('time','<',$end5)->where('uid',$loginAdmin['id'])->count();
     $yonghu6 = Db::name('users')->where('time','>',$today6)->where('time','<',$end6)->where('uid',$loginAdmin['id'])->count();
        return view('',[
           'yonghushu'=>$yonghushu,
           'jinriyonghushu'=>$jinriyonghushu,
           'dingdanshu'=>$dingdanshu,
           'jinridingdanshu'=>$jinridingdanshu,
           'zongshouru'=>$zongshouru,
           'jinrizongshouru'=>$jinrizongshouru,
           
           'yonghu1'=>$yonghu1,
           'yonghu2'=>$yonghu2,
           'yonghu3'=>$yonghu3,
           'yonghu4'=>$yonghu4,
           'yonghu5'=>$yonghu5,
           'yonghu6'=>$yonghu6,
           'dingdan1'=>$dingdan1,
            'dingdan2'=>$dingdan2,
             'dingdan3'=>$dingdan3,
              'dingdan4'=>$dingdan4,
               'dingdan5'=>$dingdan5,
                'dingdan6'=>$dingdan6,
           ]);
           
           
    }

    public function logout() {

      // 清除session
      session(null);

      // 跳出
      return redirect('/');

  }

   
}